angular.module('setting', [])
    .controller('settingCtrl', ['$scope', 'httpService', '$state', '$localStorage', 'alertmsg', function($scope, httpService, $state, $localStorage, alertmsg) {

        var firstsubmit = true;
        $scope.ischangepwdform1 = false;
        $scope.changepwd = function(bool, msg) {
            firstsubmit = true;
            if (firstsubmit) {
                if (!bool) {
                    firstsubmit = false;
                    console.log(msg)
                    httpService.query('web/change_password', msg, 'post').then(function(res) {
                        firstsubmit = true;
                        if (res.code == 200) {
                            alertmsg('修改成功，请重新登录！')
                            $localStorage.user = {};
                            $localStorage.mutian_token = '';
                            $state.go('login');
                        } else {
                            alertmsg(res.msg);
                        }
                    }, function() {
                        firstsubmit = true;
                    });
                } else {
                    $scope.ischangepwdform1 = true;
                }
            } else {
                alertmsg('请不要多次提交！');
            }

        };
    }]);
